import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/submit")
public class submit extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        System.out.println("get");
        System.out.println(username);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        BufferedReader reader = req.getReader();
//        String line=null;
//        while((line=reader.readLine()) !=null){
//            System.out.println(line);
//        }
        String name="";
         name = req.getParameter("name");
        Enumeration<String> parameter = req.getParameterNames();
        while(parameter.hasMoreElements()){
            String s = parameter.nextElement();
            System.out.println(s);
            String value= req.getParameter(name);
            System.out.println(value);
        }
        String[] hobby = req.getParameterValues("hobby");
       for(String s:hobby) {
           System.out.println(s);
       }
       }
//        String username = req.getParameter("username");
//        System.out.println("post");
//        System.out.println(username);
    }

